﻿using System;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using xEngine.DataTypes;
using xEngine.UI.Screens;
using xEngine.Rendering;
using xEngine.Input;

namespace xEngine.UI.Menu
{
    public abstract class MenuItem
    {
        #region Member Variables

        private bool _hover;

        #endregion

        #region Properties

        public Point Size { get; set; }
        public Margin Margin { get; set; }
        public Rectangle Bounds { get; set; }

        public bool IsHover
        {
            get { return _hover; }
            set
            {
                bool old = _hover;
                _hover = value;

                if (old != _hover)
                    OnHoverChange();
            }
        }

        public Screen Menu { get; protected set; }

        #endregion

        #region Constructors

        public MenuItem()
        {
            Size = new Point(0, 0);
            Margin = new Margin(0, 0, 0, 0);
        }

        #endregion

        #region Functions

        protected virtual void OnHoverChange() { }
        public virtual void OnClick(MouseButtonEventArgs e) { }

        public virtual void Initialize(Screen menu)
        {
            Menu = menu;
        }
        public virtual void LoadContent(XContentManager content) { }

        public abstract void Update(GameTime gameTime);
        public abstract void Render(GameTime gameTime);

        #endregion
    }
}
